import 'package:flutter_easyloading/flutter_easyloading.dart';

CusLoading cusLoading=CusLoading();

class CusLoading{
  int loadingCount=0;

  CusLoading(){
    //定义loading样式
    EasyLoading.instance
      ..indicatorType = EasyLoadingIndicatorType.fadingCircle
      ..maskType=EasyLoadingMaskType.black
      ..loadingStyle = EasyLoadingStyle.light
      ..userInteractions = false;
  }

  void show(){
    if (loadingCount==0) {
      EasyLoading.show(status: 'loading...');
    }
    loadingCount++;
  }
  void dismiss(){
    if (loadingCount==0) {
      return;
    }
    loadingCount--;
    if (loadingCount==0) {
      EasyLoading.dismiss();
    }
  }
  void forceClose(){
    loadingCount=0;
    EasyLoading.dismiss();
  }
}